package com.ycp.erp.warehouse.ui.binder;

import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;

import com.one.common.view.multitytype.adapter.BaseItemBinder;
import com.one.common.view.multitytype.adapter.BaseViewHolderMulti;
import com.ycp.erp.R;
import com.ycp.erp.warehouse.model.bean.ProcurementWarehouse;

import androidx.annotation.NonNull;

/**
 * Class Des:
 * Created by bjh on 2021/8/24.
 */
public class ProcyrementWarehouseSelectBinder extends BaseItemBinder<ProcurementWarehouse> {
    public ProcyrementWarehouseSelectBinder() {
        super(R.layout.item_procure_warehouse_select);
    }

    @Override
    protected void bindView(@NonNull BaseViewHolderMulti holder, ProcurementWarehouse item) {
        View ivAdd = holder.getView(R.id.ivAdd);
        View ivReduce = holder.getView(R.id.ivReduce);
        EditText etNum = holder.getView(R.id.etGoodsNum);
        EditText etGoodsPrice = holder.getView(R.id.etGoodsPrice);
        etNum.setText(String.format("%s", item.getGoodsNum()));
        ivAdd.setOnClickListener(v -> {
            item.setGoodsNum(item.getGoodsNum() + 1);
            etNum.setText(String.format("%s", item.getGoodsNum()));
        });
        ivReduce.setOnClickListener(v -> {
            if (item.getGoodsNum() > 0) {
                item.setGoodsNum(item.getGoodsNum() - 1);
                etNum.setText(String.format("%s", item.getGoodsNum()));
            }
        });
    }
}
